# snappy.cmake
# 本文件包含着从外部导入 snappy 所需要的信息

SET(SNAPPY_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_rocksdb" CACHE PATH "Path to sbappy sources")
SET(SNAPPY_INCLUDE_DIR "${LIB_INCLUDE_DIR}" CACHE PATH "snappy include directory." FORCE)
SET(SNAPPY_LIBRARIES "${LIB_INSTALL_DIR}/libsnappy.a" CACHE FILEPATH "snappy include directory." FORCE)

ExternalProject_Add(
        extern_snappy
        GIT_REPOSITORY https://github.com/google/snappy.git
        URL https://github.com/google/snappy/archive/refs/tags/1.2.1.zip
        CMAKE_ARGS
        -DCMAKE_INSTALL_PREFIX=${LIB_INSTALL_PREFIX}
        -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
        -DCMAKE_BUILD_TYPE=${LIB_BUILD_TYPE}
        BUILD_COMMAND make
)

ADD_LIBRARY(snappy STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET zlib PROPERTY IMPORTED_LOCATION ${ROCKSDB_LIBRARIES})
ADD_DEPENDENCIES(snappy extern_snappy)